#include <boost/shared_ptr.hpp>
#include <boost/thread.hpp>
#include <string>
#include <iostream>

class CAnimal;
typedef boost::shared_ptr<std::string> StringPtr;
typedef boost::shared_ptr<CAnimal> AnimalPtr;

class CAnimal
{
public:
	CAnimal(int iAge)
	{
		std::cout << "construct" << std::endl;
		m_iAge = iAge;
	}
	~CAnimal()
	{
		std::cout << "deconstruct" << std::endl;
	}
	int m_iAge;
};
void Child(StringPtr ptr)
{
	std::cout << "enter child---------" << std::endl;
	boost::this_thread::sleep_for(boost::chrono::seconds(5));
	std::cout << ptr.get()->c_str() << std::endl;
	std::cout << "enter child=========" << std::endl;
}

int main()
{
	boost::thread *pThread;
	{
		StringPtr str(new std::string("xan"));
//		boost::thread thread(Child, str);
		pThread = new boost::thread(Child, str);
	}

	std::cout << "leave domain......" << std::endl;
	pThread->join();
	return 0;
}